<template>
    <div>
        <Modal title="联系线索客户" v-model="contactClue" :mask-closable="false" width="1000" @on-cancel="handleDrawerCancel('formItem')">
            <Form :model="params" ref="formItem" :rules="createRules" label-colon :label-width="80">
                <Row type='flex'>
                    <Col span="8"><FormItem label="基本信息"><span>{{ params.user_name }} {{ params.gender_str }}<span v-if="params.age">{{ params.age }}岁</span></span></FormItem></Col>
                    <Col span="8"><FormItem label="手机号"><span>{{params.mobile}}</span></FormItem></Col>
                    <Col span="8"><FormItem label="微信号"><span>{{params.wechat_num}}</span></FormItem></Col>
                    <Col span="8"><FormItem label="抖音号"><span>{{params.dy_num}}</span></FormItem></Col>
                    <Col span="8"><FormItem label="部位"><span><tag v-for="(item, index) in params.body_parts_arr" :key="index">{{ item }}</tag></span></FormItem></Col>
                    <Col span="8"><FormItem label="渠道"><span>{{params.channel}}</span></FormItem></Col>
                    <Col><FormItem label="客服备注"><span>{{params.customer_remark}}</span></FormItem></Col>
                </Row>
                <Divider style="margin-top:0"/>

            </Form>
            <div slot="footer">
                <Button @click="handleDrawerCancel('formItem')">取消</Button>
                <Button type="primary" :loading="remarksloading" @click="handlesearch('formItem')">确定</Button>
            </div>
        </Modal>
    </div>
</template>

<script>
// import jgcheckcity from "@/components/checkcity";
import {
    clueuserinfo,
    clueusercreate,
    clueuserupdate,
    patientindexsearchcity,
    clueusercontact,
    checkPhone_Wx,
    clueusersearchrepeat,
    repeatData,
    clueuserexport,
    patientindexsearchmobile,
    clueuserrepeatuser,
    clueusersearchmobile,
} from "@api/hqapi";
export default {
    name: 'contact', // 联系线索客户
    components: {  },
    data() {
        const validateMobile = (rule, value, callback) => {
            if (value === "") {
                callback();
            } else {
                let reg = /^\d{10,12}$/;
                if (reg.test(value)) {
                    callback();
                } else {
                    callback(new Error("请输入正确的联系号码"));
                }
            }
        };
        return {
            createRules: {
                remark: [{ required: true, type: "string", message: "请输入备注原因", trigger: "blur" }],
                age: [{ required: true, message: "请填写年龄", type: 'number', trigger: 'blur,change' }],
                city: [{ required: true, message: "请选择城市", trigger: "change" }],
                oneDiseases: [{ required: true, message: "请选择一级病种", trigger: "change" }],
                mobile: [{ validator: validateMobile, trigger: "blur" }],
                twoDiseases: [{ required: true, message: "请选择二级病种", trigger: "change" }],
                patientStatus: [{ required: true, message: "请选择患者状态", trigger: "change" }],
                day: [{ required: true, type: "number", message: "请输入回访时间", trigger: "blur" }],
                day1: [{ required: true, type: "number", message: "请输入预约", trigger: "blur" }],
            },
            contactClue: false,
            params: {id: ''},
            remarksloading: false
        }
    },
    methods: {
        initial(row) {
            this.contactClue = true
            this.askData(row.id)
        },
        askDatas() {
            this.$emit('askData');
        },
        askData(id) {
            clueuserinfo({ id, type: 2 }).then((res) => {
                if (res.contact.length && res.contact[res.contact.length - 1].status_name === '转客户') {
                    this.contactClue = false
                    this.$Modal.warning({
                        title: '提示消息',
                        content: '该条线索已被转客户，请处理其它线索',
                        onOk: () => {
                            this.askDatas()
                        }
                    });
                    return
                }
                this.params = res.info
            })
        }
    },
};
</script>
